/*
 * libc/time/time.c
 */

#include <time.h>
#include <nxos.h>
#include "time_impl.h"

time_t time(time_t * t)
{
    time_t secs;
    struct tm tm;
    NX_Time nxtm;
    NX_TimeGet(&nxtm);

    tm.tm_year = nxtm.year;
    tm.tm_mon = nxtm.month;
    tm.tm_mday = nxtm.day;
    tm.tm_hour = nxtm.hour;
    tm.tm_min = nxtm.minute;
    tm.tm_sec = nxtm.second;
    
	secs = __tm_to_secs(&tm);

    if (t)
        *t = secs;

    return secs;
}
